<!DOCTYPE html>
<html>
<!-- Mirrored from www.zi-han.net/theme/hplus/login.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:18:23 GMT -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理后台 - 登录</title>
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="{{ asset('css/admin/bootstrap.min14ed.css?v=3.3.6') }}" rel="stylesheet">
    <link href="{{ asset('css/admin/font-awesome.min93e3.css?v=4.4.0') }}" rel="stylesheet">

    <link href="{{ asset('css/admin/animate.min.css') }}" rel="stylesheet">
    <link href="{{ asset('css/admin/style.min862f.css?v=4.1.0') }}" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    {{--<script>if(window.top !== window.self){ window.top.location = window.location;}</script>--}}
</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name">彩蝠鲜果</h1>

            </div>
            <h3>欢迎使用管理后台</h3>

            <form class="m-t" role="form" id="login-form">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="用户名" required="" id="username" name="unit_login">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" placeholder="密码" required="" id="password" name="password">
                </div>
                <button type="button" class="btn btn-primary block full-width m-b" id="login-btn">登 录</button>
                </p>

            </form>
        </div>
    </div>
    <!-- Jquery -->
    <script src="{{url('js/jquery.min.js')}}"></script>
    <script>
        $(document).keypress(function(e) {
            // 回车键事件
            if(e.which == 13) {
                jQuery("#login-btn").click();
            }
        });

        jQuery(function($) {

            $('#login-btn').click(function(){
                var username = $('#username').val();
                var password = $('#password').val();

                $.ajax({
                    type:"post",
                    url:'{{route('Api.Admin.Auth.signInAdmin')}}',
                    dataType:"json",
                    data:{"username":username,"password":password},
                    success:function(obj){
                        if(obj.level == "success"){
                            console.log(obj);
                            window.location.href="{{route('Admin.Page.userList')}}";
                        }else {
                            alert(obj.message);
                        }
                    },
                    error:function(obj){
                        var datajson = obj.responseJSON;
                        alert(datajson.message);
                    }
                });
            });
        });
    </script>
</body>
</html>
